<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
    />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>03.封装渲染函数实现</title>
    <script src="../lib/react.js"></script>
    <script src="../lib/react-dom.js"></script>
    <script src="../lib/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      const root = ReactDOM.createRoot(document.getElementById("root"))
      let msg = "hello"

      function changeText() {
        msg = "react"
        rootRender()
      }

      rootRender()

      function rootRender() {
        root.render(
          <div>
            <div>{msg}</div>
            <button onClick={changeText}>按钮</button>
          </div>
        )
      }
    </script>
  </body>
</html>
